#include<stdio.h>
#include<fcntl.h>
#include<unistd.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<string.h>
#include<stdlib.h>

int main(int argc, char const *argv[])
{
    int fd = open("dup2_test.txt", O_RDWR | O_CREAT, 0666);
    dup2(fd, 1);
    dup2(fd, 2);
    write(fd, "hello world\n", 12);
    fprintf(stdout, "stdout\n");
    fprintf(stderr, "stderr\n");
    close(fd);
    return 0;
}
